package com.topcheer.base.gatewaynacos.common;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * @author xutao
 * @Package com.topcheer.gateway.common
 * @Description: ${todo}
 * @date 2020/1/4 21:34
 */
public class JacksonUtils {
    private static ObjectMapper objectMapper = new ObjectMapper();

    public static String write(Object object) throws JsonProcessingException {
        return objectMapper.writeValueAsString(object);
    }

    public static <T> T read(String content, Class<T> clz) throws JsonProcessingException {
        return objectMapper.readValue(content,clz);
    }

    public static ObjectMapper getObjectMapper() {
        return objectMapper;
    }
}
